﻿using System;
using System.Web;
using System.Web.Routing;
using System.Web.Mvc;
using PhotoGallery.Infrastructure.Modules;

namespace PhotoGallery.Modules
{
    public class AuthorityModule : IModule
    {
        private readonly string[] controllerNamespaces;

        public AuthorityModule()
        {
            this.controllerNamespaces = new String[] { "PhotoGallery.Modules.Authority.Controllers" };
        }

        #region IModule Members

        public void Initialize()
        {
        }

        public void Unload()
        {
        }

        public void RegisterRoutes(RouteCollection routes)
        {           
            routes.MapRoute(
                "Authority-Role", // Route name
                "Authority/Role/{action}/{id}", // URL with parameters
                new { controller = "Role", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                new { controller = "(Role)", action = "(Index|Add|Create|Edit|Update|Delete|CheckRoleName|Save)" },
                controllerNamespaces
            );

            routes.MapRoute(
                "Authority-Operation", // Route name
                "Authority/Operation/{action}/{id}", // URL with parameters
                new { controller = "Operation", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
                new { controller = "(Operation)", action = "(Index|Add|Create|Edit|Update|Delete|CheckOperation)" },
                controllerNamespaces
            );

            routes.MapRoute(
               "Authority-Account-Role", // Route name
               "Authority/AccountRole/{action}/{id}", // URL with parameters
               new { controller = "AccountRole", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
               new { controller = "(AccountRole)", action = "(Index|Add|Create|Edit|Update|Delete|UpdateAccountRoles)" },
               controllerNamespaces
           );


        }

        public void RegisterModelBinders(ModelBinderDictionary binders)
        {
        }

        #endregion
    }
}
